// eslint-disable-next-line import/no-extraneous-dependencies
import { Request, Response } from 'express';

function getFakeCaptcha(req: Request, res: Response) {
  return res.json('captcha-xxx');
}

function verify(req: Request, res: Response) {
  return res.json({
    "data":false, 
	  "errCode": 0,
    "errMsg": null,
    "extend": null,
    "redirectUrl": null,
    "success": true,
    "total": 0
  });
}

function setPswd(req: Request, res: Response) {
  return res.json({
    "data":null, 
	  "errCode": 0,
    "errMsg": null,
    "extend": null,
    "redirectUrl": null,
    "success": true,
    "total": 0
  });
}

export default {
  'POST  /api/login/account': (req: Request, res: Response) => {
    const { password, userName, type } = req.body;
    if (password === 'ant.design' && userName === 'admin') {
      res.send({
        status: 'ok',
        type,
        currentAuthority: 'admin',
      });
      return;
    }
    if (password === 'ant.design' && userName === 'user') {
      res.send({
        status: 'ok',
        type,
        currentAuthority: 'user',
      });
      return;
    }
    if (type === 'mobile') {
      res.send({
        status: 'ok',
        type,
        currentAuthority: 'admin',
      });
      return;
    }
    res.send({
      status: 'error',
      type,
      currentAuthority: 'guest',
    });
  },
  'GET  /api/login/captcha': getFakeCaptcha,
  'GET /oa/user/userPasswordVerify': verify,
  'POST /api/user/changePassword': setPswd,
};
